﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;

using DataBusiness;

namespace UI.CasingsDesign
{
    public partial class frmCasingBasicDesign : DevExpress.XtraEditors.XtraForm
    {
        private DataTable CasDesignDt = new DataTable();
        public frmCasingBasicDesign(float WallSize)
        {
            InitializeComponent();
            BindDataSource();
        }
        /// <summary>
        /// 为SteelGradeComb、WallThickComb、BuckleComb上个下拉框绑定数据
        /// </summary>
        private void BindDataSource()
        {
            DataTable APIData = CasDesignDataInputBLL.getAPISet();

            

            //SteelGradeComboBox
            SteelGradeComboBox.Items.Add("L-80");
            SteelGradeComboBox.Items.Add("N-80E");
            SteelGradeComboBox.Items.Add("P-105");
            SteelGradeComboBox.Items.Add("P-105E");
            //WallThickComboBox
            WallThickComboBox.Items.Add("5.51");
            WallThickComboBox.Items.Add("7.82");
            WallThickComboBox.Items.Add("6.45");
            WallThickComboBox.Items.Add("9.92");
            //BuckleComboBox
            BuckleComboBox.Items.Add("梯形");
            BuckleComboBox.Items.Add("长圆");
            BuckleComboBox.Items.Add("短圆");

            InitDt();
            BindingSource bindSource = new BindingSource();
            gridConCasingDesign.DataSource = bindSource;
            bindSource.DataSource = CasDesignDt;


        }

        /// <summary>
        /// 创建表
        /// </summary>
        /// <returns></returns>
        private void InitDt()
        {
            CasDesignDt.Columns.Add("inputLength", typeof(float));
            CasDesignDt.Columns.Add("wallSize", typeof(float));
            CasDesignDt.Columns.Add("steelGrade", typeof(string));
            CasDesignDt.Columns.Add("wallThickness", typeof(float));
            CasDesignDt.Columns.Add("buckleType", typeof(string));

        }

        private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            Console.WriteLine("----------------------------------------------");
            for (int i = 0; i < CasDesignDt.Rows.Count; i++)
            {
                for (int j = 0; j < CasDesignDt.Columns.Count; j++)
                {
                    Console.Write(CasDesignDt.Rows[i][j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine("----------------------------------------------");
        }
    }
}